package com.lc.user.express.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lc.user.express.R;
import com.lc.user.express.app.AppContext;
import com.lc.user.express.model.MyIntegralModel;

import java.util.List;

/**
 * Created by Administrator on 2016/3/15.
 */
public class IntegraAdapter extends BaseListAdapter<MyIntegralModel> {

    public IntegraAdapter(Context context, List<MyIntegralModel> data) {
        super(context, data);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        MyIntegralModel integralModel = data.get(position);
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_integral, null);
            viewHolder = new ViewHolder();
            AppContext.ScaleScreenHelper.loadView((ViewGroup) convertView);
            viewHolder.money = (TextView) convertView.findViewById(R.id.money);
            viewHolder.integra = (TextView) convertView.findViewById(R.id.integral);
            viewHolder.starttime = (TextView) convertView.findViewById(R.id.starttime);
            viewHolder.endtime = (TextView) convertView.findViewById(R.id.endtime);
            convertView.setTag(viewHolder);
        }
        setContextView(convertView, integralModel);
        return convertView;
    }

    private void setContextView(View convertView, MyIntegralModel integralModel) {
        ViewHolder viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.money.setText(integralModel.getMoney());
        viewHolder.integra.setText(integralModel.getIntegral());
        viewHolder.starttime.setText(integralModel.getStarttime());
        viewHolder.endtime.setText(integralModel.getEndtime());
    }

    public class ViewHolder {
        TextView money;
        TextView starttime;
        TextView endtime;
        TextView integra;

    }
}
